/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * File Name          : freertos.c
  * Description        : Code for freertos applications
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
#include "main.h"
#include "cmsis_os.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "FreeRTOS_Task.h"

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */

/* USER CODE END Variables */
/* Definitions for U3AnalyseTask */
osThreadId_t U3AnalyseTaskHandle;
const osThreadAttr_t U3AnalyseTask_attributes = {
  .name = "U3AnalyseTask",
  .stack_size = 512 * 4,
  .priority = (osPriority_t) osPriorityAboveNormal,
};
/* Definitions for U2AnalyseTask */
osThreadId_t U2AnalyseTaskHandle;
const osThreadAttr_t U2AnalyseTask_attributes = {
  .name = "U2AnalyseTask",
  .stack_size = 512 * 4,
  .priority = (osPriority_t) osPriorityAboveNormal,
};
/* Definitions for U4AnaylseTask */
osThreadId_t U4AnaylseTaskHandle;
const osThreadAttr_t U4AnaylseTask_attributes = {
  .name = "U4AnaylseTask",
  .stack_size = 512 * 4,
  .priority = (osPriority_t) osPriorityAboveNormal,
};
/* Definitions for U6AnaylseTask */
osThreadId_t U6AnaylseTaskHandle;
const osThreadAttr_t U6AnaylseTask_attributes = {
  .name = "U6AnaylseTask",
  .stack_size = 512 * 4,
  .priority = (osPriority_t) osPriorityAboveNormal,
};
/* Definitions for PeripheralTask */
osThreadId_t PeripheralTaskHandle;
const osThreadAttr_t PeripheralTask_attributes = {
  .name = "PeripheralTask",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for KeyScanTask */
osThreadId_t KeyScanTaskHandle;
const osThreadAttr_t KeyScanTask_attributes = {
  .name = "KeyScanTask",
  .stack_size = 128 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for BackupTask */
osThreadId_t BackupTaskHandle;
const osThreadAttr_t BackupTask_attributes = {
  .name = "BackupTask",
  .stack_size = 256 * 4,
  .priority = (osPriority_t) osPriorityLow,
};

/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */

/* USER CODE END FunctionPrototypes */

void StartU3Task(void *argument);
void StartU2Task(void *argument);
void StartU4Task(void *argument);
void StartU6Task(void *argument);
void StartPeriTask(void *argument);
void StartKeyScanTask(void *argument);
void StartBackupTask(void *argument);

void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */

/**
  * @brief  FreeRTOS initialization
  * @param  None
  * @retval None
  */
void MX_FREERTOS_Init(void) {
  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */

  /* Create the thread(s) */
  /* creation of U3AnalyseTask */
  U3AnalyseTaskHandle = osThreadNew(StartU3Task, NULL, &U3AnalyseTask_attributes);

  /* creation of U2AnalyseTask */
  U2AnalyseTaskHandle = osThreadNew(StartU2Task, NULL, &U2AnalyseTask_attributes);

  /* creation of U4AnaylseTask */
  U4AnaylseTaskHandle = osThreadNew(StartU4Task, NULL, &U4AnaylseTask_attributes);

  /* creation of U6AnaylseTask */
  U6AnaylseTaskHandle = osThreadNew(StartU6Task, NULL, &U6AnaylseTask_attributes);

  /* creation of PeripheralTask */
  PeripheralTaskHandle = osThreadNew(StartPeriTask, NULL, &PeripheralTask_attributes);

  /* creation of KeyScanTask */
  KeyScanTaskHandle = osThreadNew(StartKeyScanTask, NULL, &KeyScanTask_attributes);

  /* creation of BackupTask */
  BackupTaskHandle = osThreadNew(StartBackupTask, NULL, &BackupTask_attributes);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

  /* USER CODE BEGIN RTOS_EVENTS */
  /* add events, ... */
  /* USER CODE END RTOS_EVENTS */

}

/* USER CODE BEGIN Header_StartU3Task */
/**
  * @brief  Function implementing the U3AnalyseTask thread.
  * @param  argument: Not used
  * @retval None
  */
/* USER CODE END Header_StartU3Task */
__weak void StartU3Task(void *argument)
{
  /* USER CODE BEGIN StartU3Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartU3Task */
}

/* USER CODE BEGIN Header_StartU2Task */
/**
* @brief Function implementing the U2AnalyseTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartU2Task */
__weak void StartU2Task(void *argument)
{
  /* USER CODE BEGIN StartU2Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartU2Task */
}

/* USER CODE BEGIN Header_StartU4Task */
/**
* @brief Function implementing the U4AnaylseTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartU4Task */
__weak void StartU4Task(void *argument)
{
  /* USER CODE BEGIN StartU4Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartU4Task */
}

/* USER CODE BEGIN Header_StartU6Task */
/**
* @brief Function implementing the U6AnaylseTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartU6Task */
__weak void StartU6Task(void *argument)
{
  /* USER CODE BEGIN StartU6Task */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartU6Task */
}

/* USER CODE BEGIN Header_StartPeriTask */
/**
* @brief Function implementing the PeripheralTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartPeriTask */
__weak void StartPeriTask(void *argument)
{
  /* USER CODE BEGIN StartPeriTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartPeriTask */
}

/* USER CODE BEGIN Header_StartKeyScanTask */
/**
* @brief Function implementing the KeyScanTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartKeyScanTask */
__weak void StartKeyScanTask(void *argument)
{
  /* USER CODE BEGIN StartKeyScanTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartKeyScanTask */
}

/* USER CODE BEGIN Header_StartBackupTask */
/**
* @brief Function implementing the BackupTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartBackupTask */
__weak void StartBackupTask(void *argument)
{
  /* USER CODE BEGIN StartBackupTask */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartBackupTask */
}

/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */

/* USER CODE END Application */

